home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
hypercrd
/
hc1_2_x
/
stabilzr.sit
/
The Stabilizer
/
stack.txt
< prev
Wrap
Text File
|
1989-02-05
|
29KB
|
799 lines
-- stack: in
-- format: 8 (HyperCard 1)
-- flags: 0x1000 (none)
-- protect password hash: 0
-- maximum user level: 5 (scripting)
-- window: Rect(x1=0, y1=0, x2=0, y2=0)
-- screen: Rect(x1=0, y1=0, x2=0, y2=0)
-- card dimensions: w=0 h=0
-- scroll: x=0 y=0
-- background count: 6
-- first background id: 2175
-- card count: 34
-- first card id: 9877
-- list block id: 18180
-- print block id: 13286
-- font table block id: 0
-- style table block id: 0
-- free block count: 0
-- free size: 0 bytes
-- total size: 127296 bytes
-- stack block size: 23552 bytes
-- created by hypercard version: 0x00000000
-- compacted by hypercard version: 0x01208000
-- modified by hypercard version: 0x01208000
-- opened by hypercard version: 0x01208000
-- patterns[0]: 0x0000000000000000
-- patterns[1]: 0x8000000008000000
-- patterns[2]: 0x8800220088002200
-- patterns[3]: 0x8888222288882222
-- patterns[4]: 0x88AA22AA88AA22AA
-- patterns[5]: 0xCCAA33AACCAA33AA
-- patterns[6]: 0xEEAABBAAEEAABBAA
-- patterns[7]: 0xEEBBBBEEEEBBBBEE
-- patterns[8]: 0xFFBBFFEEFFBBFFEE
-- patterns[9]: 0xFFBBFFFFFFBBFFFF
-- patterns[10]: 0x8010022001084004
-- patterns[11]: 0xFFFFFFFFFFFFFFFF
-- patterns[12]: 0x8822882288228822
-- patterns[13]: 0x1122448811224488
-- patterns[14]: 0xC4800C6843023026
-- patterns[15]: 0xB130031BD8C00C8D
-- patterns[16]: 0xAA00AA00AA00AA00
-- patterns[17]: 0x8822552288225522
-- patterns[18]: 0x8855225588552255
-- patterns[19]: 0x77DD77DD77DD77DD
-- patterns[20]: 0x8000000000000000
-- patterns[21]: 0xAA55AA55AA55AA55
-- patterns[22]: 0x038448300C020101
-- patterns[23]: 0x8244394482010101
-- patterns[24]: 0x8814224188412214
-- patterns[25]: 0x8080413E080814E3
-- patterns[26]: 0x22048C7422179810
-- patterns[27]: 0xBE808808EB088880
-- patterns[28]: 0x25C8328964244C92
-- patterns[29]: 0xA29C41BE2AC914EB
-- patterns[30]: 0x40A00000040A0000
-- patterns[31]: 0x8040200002040800
-- patterns[32]: 0xAA00800088008000
-- patterns[33]: 0xFF80808080808080
-- patterns[34]: 0x081C22C180010204
-- patterns[35]: 0xFF808080FF080808
-- patterns[36]: 0xF87422478F172271
-- patterns[37]: 0xBF00BFBFB0B0B0B0
-- patterns[38]: 0xFF7FBE5DA2418000
-- patterns[39]: 0xFAF5FAF5A050A050
-- checksum: 0x0
----- HyperTalk script -----
--Copyright ©1988 - Scott McGilliard - all rights reserved
--Thank you to: Andrew Gilmartin (Brown University) for XFCN PopUpMenu
on openStack
global saveMsg
hide msg
hide menuBar
put loc of msg into saveMsg
push card "Expenses"
get card field "allExpenses" of card "whichMonths"
if it = empty then exit openStack
get the date
convert it to seconds
if it >= line 2 of card field "startMonth" of card "Year Totals" then
answer "It's time to recalculate, do it now?" with "No" or "Yes"
if it is "Yes" then
put last word of the long date into whichYear
if word 1 of item 2 of the long date Γëá "January" then put " -" && whichYear + 1 after whichYear
set loc of msg to 19,106
put "Estimating expenses for" && whichYear & ", please wait."
get line 2 of card field "startMonth" of card "Year Totals"
convert it to long date
add 1 to last item of it
convert it to seconds
put it into line 2 of card field "startMonth" of card "Year Totals"
doEstimate
doMath
hide msg
end if
end if
end openStack
on idle
global moreExpenses
if moreExpenses = 1 then addExpense
set cursor to 5
pass idle
end idle
on helpIndex
visual venetian blinds to gray
visual venetian blinds
go card "HelpIndex"
end helpIndex
on addExpense
global expenseAmount,expense,moreExpenses
push card
Get card field "allExpenses" of card "whichMonths"
if the number of lines of it >= 48 then
answer "You can not enter more than 48 items" with "OK"
get field expense3 of card "Expenses"
if line 16 of it = empty then noMore
put empty into moreExpenses
exit addExpense
end if
set numberFormat to "0.00"
repeat forever
ask "Please enter an expense item"
repeat
if "," is in it then
put offset (",",it) into er
delete char er of it
else
exit repeat
end if
end repeat
put it into expenseItem
if expenseItem = empty then exit repeat
if the length of expenseItem > 18 then
answer "Expense items can have only 18 characters" with "OK"
exit addExpense
end if
put expenseItem&"," into expense
answer "Do you pay the same amount every time?" with "No" or "Yes"
if it is "yes" then
repeat forever
ask "Please enter the amount for"&&expenseItem
if it is empty then
answer "Do you want to delete this expense?" with "Yes" or "No"
if it is "yes" then
put empty into expense
exit repeat
else
next repeat
end if
else
exit repeat
end if
end repeat
if expense = empty then next repeat
put "$" into expenseAmount
if char 1 of it = "$" then delete char 1 of it
repeat
if "," is in it then
put offset (",",it) into er
delete char er of it
else
exit repeat
end if
end repeat
add 0 to it
put it & "," after expenseAmount
put expenseAmount after expense
answer "Do you pay this expense every month?" with "No" or "Yes"
else
put "variable," into expenseAmount
put expenseAmount after expense
end if
if it is "yes" and expenseAmount Γëá "variable," then
put "Every Month" after expense
exit repeat
else
visual venetian blinds to gray
visual venetian blinds
go card "whichMonths"
put empty into moreExpenses
exit addExpense
end if
end repeat
doAlphabet
answer "Are you finished adding expenses?" with "Yes" or "No"
if it = "yes" then
put the number of lines of card field "allExpenses" of card "whichMonths" into test1
put the number of lines of field "expense" of card "Expenses" into test2
add the number of lines of field "expense2" of card "Expenses" to test2
add the number of lines of field "expense3" of card "Expenses" to test2
if test2 < test1 then
noMore
else
put empty into moreExpenses
end if
end if
end addExpense
on doAlphabet
global expense
set cursor to 4
set loc of msg to 19,106
put "Please wait"
if expense = empty then
hide msg
exit doAlphabet
end if
repeat with x = 1 to the length of item 1 of expense
put the charToNum of char x of item 1 of expense into temp
if temp >= 97 and temp <= 122 then
put temp - 32 into temp
put the numToChar of temp into char x of item 1 of expense
end if
end repeat
put card field "allExpenses" of card "whichMonths" into allExpenses
if allExpenses = empty then
put expense into card field "allExpenses" of card "whichMonths"
put empty into expense
hide msg
exit doAlphabet
end if
put item 1 of expense into ex
put 1 into y
put 1 into z
repeat
if ex = item 1 of line y of allExpenses then
answer "You can't enter the same expense item twice." with "OK"
ask "Please enter a different name for" && ex
if it = ex or it = empty then
put empty into expense
hide msg
exit doAlphabet
else
repeat
if "," is in it then
put offset (",",it) into er
delete char er of it
else
exit repeat
end if
end repeat
put it into ex
repeat
if the length of ex > 18 then
delete last char of ex
else
exit repeat
end if
end repeat
repeat with x = 1 to the length of ex
put the charToNum of char x of ex into temp
if temp >= 97 and temp <= 122 then
put temp - 32 into temp
put the numToChar of temp into char x of ex
end if
end repeat
put ex into item 1 of expense
put 1 into y
put 1 into z
end if
end if
if line y of allExpenses = empty then
put return & expense after last line of card field "allExpenses" of card "whichMonths"
put empty into expense
hide msg
exit doAlphabet
end if
if the charToNum of char z of ex = the charToNum of char z of item 1 of line y of allExpenses then
add 1 to z
if char z of item 1 of line y of allExpenses = empty then
add 1 to y
put 1 into z
next repeat
end if
if char z of ex = empty then
put expense & return before line y of card field "allExpenses" of card "whichMonths"
put empty into expense
hide msg
exit doAlphabet
end if
next repeat
end if
if the charToNum of char z of ex < the charToNum of char z of item 1 of line y of allExpenses then
put expense & return before line y of card field "allExpenses" of card "whichMonths"
put empty into expense
hide msg
exit doAlphabet
else
add 1 to y
put "1" into z
next repeat
end if
end repeat
hide msg
end doAlphabet
on noMore
global moreExpenses
set loc of msg to 19,106
put "This will take a couple of minutes, please wait."
put empty into moreExpenses
set cursor to 4
set lockScreen to true
put card field "allExpenses" of card "whichMonths" into allExpenses
repeat with x = 2 to 13
put empty into field expense of card x
put empty into field amount of card x
put empty into field expense2 of card x
put empty into field amount2 of card x
end repeat
put empty into field expense of card "Expenses"
put empty into field expense2 of card "Expenses"
put empty into field expense3 of card "Expenses"
repeat with i = 1 to the number of lines in allExpenses
put item 1 of line i of allExpenses into expenseName
put expenseName & return after field expense of card "Expenses"
if item 3 of line i of allExpenses = "Every Month" then
repeat with x = 2 to 13
put expenseName & return after field expense of card x
put item 2 of line i of allExpenses & return after field amount of card x
end repeat
else
if item 2 of line i of allExpenses = "Variable" then
repeat with x = 3 to the number of items in line i of allExpenses
put word 1 of item x of line i of allExpenses into which
put expenseName & return after field expense of card which
put last word of item x of line i of allExpenses & return after field amount of card which
end repeat
else
repeat with x = 3 to the number of items in line i of allExpenses
put item x of line i of allExpenses into which
put expenseName & return after field expense of card which
put item 2 of line i of allExpenses & return after field amount of card which
end repeat
end if
end if
end repeat
repeat with x = 2 to 13
put line 16 to 30 of field expense of card x into field expense2 of card x
delete line 16 to 30 of field expense of card x
put line 16 to 30 of field amount of card x into field amount2 of card x
delete line 16 to 30 of field amount of card x
end repeat
put line 17 to 32 of field expense of card "Expenses" into field expense2 of card "Expenses"
put line 33 to 48 of field expense of card "Expenses" into field expense3 of card "Expenses"
delete line 17 to 48 of field expense of card "Expenses"
hide msg
end noMore
on seeItems
put card field "allExpenses" of card "whichMonths" into allExpenses
put (item 2 of the clickLoc - 39) div 16 into whichLine
put the short name of the target into whichField
if line whichLine of field whichField is empty then exit seeItems
get line whichLine of field whichField
repeat with i = 1 to the number of lines in allExpenses
if it = item 1 of line i of allExpenses then
put line i of allExpenses into theList
exit repeat
end if
end repeat
if item 3 of theList = "Every Month" then put "," & card field "monthList" of card "Expenses" after theList
put the mouseloc into listHere
put item 1 of listHere + 1 into horiz
put item 2 of listHere - 10 into vert
get the number of items in theList
put vert + (it * 17) into length
if length > 314 then subtract (length - 324) from vert
get PopUpMenu(theList, 1, vert, horiz)
put item it of theList into whatCard
if it = 1 then
visual barn door close slowly to gray
visual barn door open slowly
go card whatCard
if the result Γëá empty then
repeat
answer "Automatic cost adjustment for this expense?" with "Help" or "Yes" or "No"
if it = "Help" then
push card
visual venetian blinds
go card it
show card field "Cost"
repeat until the mouse is down
end repeat
visual venetian blinds
pop card
else
exit repeat
end if
end repeat
if it = "Yes" then
go card "template"
doMenu "New Card"
put item 1 of theList into bill
set name of this card to bill
put "," & bill after line 3 of card field "startMonth" of card "Year Totals"
repeat with y = 1 to the number of fields
put field y of card "template" into field y of card bill
end repeat
put bill into field "title" of card bill
put field "months" of card bill into tempMon
set numberFormat to "0.00"
if item 3 of theList = "Every Month" then
set numberFormat to "0"
ask "Enter amount for"&& bill && "in" && last item of the long date - 1 with item 2 of theList
set numberFormat to "0.00"
repeat
if "," is in it then
put offset (",",it) into er
delete char er of it
else
exit repeat
end if
end repeat
if it = empty then put item 2 of the list into it
if char 1 of it = "$" then delete char 1 of it
add 0 to it
put "$" before it
repeat with y = 1 to 12
put item 2 of theList into line y of act
put it into line y of amo
end repeat
else
if item 2 of theList = "variable" then
put theList into oldList
repeat with i = 3 to the number of items in theList
ask "Enter amount for 1 yr before last" && word 1 of item i of theList with last word of item i of theList
repeat
if "," is in it then
put offset (",",it) into er
delete char er of it
else
exit repeat
end if
end repeat
if it = empty then put last word of item i of theList into it
if char 1 of it = "$" then delete char 1 of it
add 0 to it
put "$" before it
repeat with x = 1 to 12
if word 1 of item i of theList = line x of tempMon then exit repeat
end repeat
put last word of item i of theList into line x of act
put it into line x of amo
end repeat
else
put theList into oldList
set numberFormat to "0"
ask "Enter amount for"&& bill && "in" && last item of the long date - 1 with item 2 of theList
repeat
if "," is in it then
put offset (",",it) into er
delete char er of it
else
exit repeat
end if
end repeat
set numberFormat to "0.00"
if it = empty then put item 2 of the list into it
if char 1 of it = "$" then delete char 1 of it
add 0 to it
put "$" before it
repeat with i = 3 to the number of items in theList
repeat with x = 1 to 12
if word 1 of item i of theList = line x of tempMon then exit repeat
end repeat
put item 2 of theList into line x of act
put it into line x of amo
end repeat
end if
set cursor to 4
end if
put act into field "actual" of card bill
put amo into field "amount" of card bill
put "0" into totalAct
put "0" into totalAmo
repeat with y = 1 to 12
delete char 1 of line y of act
delete char 1 of line y of amo
add line y of act to totalAct
add line y of amo to totalAmo
end repeat
set numberFormat to "0.0"
put ((totalAct - totalAmo)/totalAmo)*100 into inc
if inc < 0 then put 0 into inc
put inc & "%" into line 2 of field "increase" of card bill
set numberFormat to "0.00"
repeat with y = 1 to 12
if line y of act Γëá empty then
put "$" & line y of amo + (line y of amo * inc/100) into line y of pro
put "$" & line y of amo - (line y of amo * inc/100) into line y of bas
end if
end repeat
put pro into field "projected" of card bill
put bas into field "base" of card bill
if item 2 of theList = "Variable" then
get word 1 of item 2 of the long date
repeat with i = 1 to 12
if it = line i of tempMon then exit repeat
end repeat
put i into t
repeat with i = i to 12
put line i of field "actual" of card bill into line i of field "amount" of card bill
put line i of field "amount" of card bill into line i of field "base" of card bill
if line i of act Γëá empty then
put "$" & line i of act + (line i of act * inc/100) into line i of field "projected" of card bill
put "$" & line i of act - (line i of act * inc/100) into line i of field "base" of card bill
end if
put empty into line i of field "actual" of card bill
end repeat
repeat
answer "Estimate" && bill && "and recalculate?" with "Help" or "Yes" or "No"
if it = "Help" then
push card
visual venetian blinds
go card it
show card field "Estimate"
repeat until the mouse is down
end repeat
visual venetian blinds
pop card
else
exit repeat
end if
end repeat
if it is "Yes" then
set loc of msg to 19,106
put "Estimating expense, please wait."
repeat with t = t to 12
get line t of field "amount" of card bill
if it Γëá empty then
put line t of field "projected" of card bill into proAm
put proAm into line t of field "actual" of card bill
put line t of tempMon into whichMonth
repeat with s = 1 to the number of items in theList
if whichMonth is in item s of theList then exit repeat
end repeat
put proAm into last word of item s of theList
repeat with y = 1 to 3
if bill is in field y of card whichMonth then
repeat with i = 1 to the number of lines in field y of card whichMonth
if bill = line i of field y of card whichMonth then
put proAm into line i of field (y + 1) of card whichMonth
exit repeat
end if
end repeat
exit repeat
end if
end repeat
repeat with i = 1 to the number of lines in allExpenses
if bill = item 1 of line i of allExpenses then
put theList into line i of card field "allExpenses" of card "whichMonths"
exit repeat
end if
end repeat
end if
end repeat
doMath
end if
end if
end if
end if
else
if whatCard = "Every Month" then
answer "You can't go to every month at once." with "OK"
exit seeItems
else
put word 1 of whatCard into whatCard
end if
visual barn door close slowly to gray
visual barn door open slowly
go card whatCard
end if
end seeItems
on doEstimate
set cursor to 4
put last word of the long date into whichYear
if word 1 of item 2 of the long date Γëá "January" then put " -" && whichYear + 1 after whichYear
put whichYear into field "thisYear1" of card "template"
put whichYear into field "thisYear2" of card "template"
put "SUMMARY FOR" && whichYear into card field "title" of card "Year Totals"
if whichYear = last word of the long date then
put whichYear - 1 into field "lastYear" of card "template"
else
subtract 1 from first word of whichYear
subtract 1 from last word of whichYear
put whichYear into field "lastYear" of card "template"
end if
put card field "allExpenses" of card "whichMonths" into allExpenses
put line 3 of card field "startMonth" of card "Year Totals" into whichBill
put field "months" of card "template" into tempMon
repeat with i = 2 to the number of items in whichBill
put item i of whichBill into bill
repeat with x = 1 to the number of lines in allExpenses
if bill = item 1 of line x of allExpenses then
put line x of allExpenses into theList
exit repeat
end if
end repeat
put field "thisYear1" of card "template" into field "thisYear1" of card bill
put field "thisYear2" of card "template" into field "thisYear2" of card bill
put field "lastYear" of card "template" into field "lastYear" of card bill
put field "amount" of card bill into amo
put field "actual" of card bill into act
put field "projected" of card bill into pro
repeat with y = 1 to 12
if line y of amo Γëá empty and line y of act = empty then put line y of pro into line y of act
end repeat
if item 2 of theList Γëá "Variable" then
repeat with y = 1 to 12
if line y of act Γëá empty then
put line y of act into test
exit repeat
end if
end repeat
repeat with y = 1 to 12
if line y of act Γëá empty and line y of act Γëá test then exit repeat
end repeat
repeat with z = y to 12
if line z of amo Γëá empty then put test into line z of amo
end repeat
put amo into field "base" of card bill
put act into field "amount" of card bill
repeat with z = 1 to y - 1
if line z of act Γëá empty then
put line y of act into line z of act
put line y of act into line z of field "projected" of card bill
end if
end repeat
put line y of act into test2
delete char 1 of test
delete char 1 of test2
set numberFormat to "0.0"
put ((test2 - test)/test)*100 into inc
if inc < 0 then put 0 into inc
put inc & "%" into line 2 of field "increase" of card bill
set numberFormat to "0.00"
repeat with z = y to 12
if line z of amo Γëá empty then
delete char 1 of line z of act
put "$" & line z of act + (line z of act * inc/100) into line z of field "projected" of card bill
put "$" & line z of act + (line z of act * inc/100) into item 2 of theList
end if
put empty into line z of act
end repeat
put act into field "actual" of card bill
else
put amo into field "base" of card bill
put act into field "amount" of card bill
put empty into field "actual" of card bill
put "0" into totalAct
put "0" into totalAmo
repeat with y = 1 to 12
delete char 1 of line y of act
delete char 1 of line y of amo
add line y of act to totalAct
add line y of amo to totalAmo
end repeat
set numberFormat to "0.0"
put ((totalAct - totalAmo)/totalAmo)*100 into inc
if inc < 0 then put 0 into inc
put inc & "%" into line 2 of field "increase" of card bill
set numberFormat to "0.00"
repeat with y = 1 to 12
if line y of amo Γëá empty then put "$" & line y of act + (line y of act * inc/100) into line y of field "projected" of card bill
end repeat
end if
repeat with t = 1 to 12
get line t of field "projected" of card bill
if it Γëá empty then
put it into proAm
put line t of tempMon into whichMonth
if item 2 of theList = "variable" then
repeat with s = 1 to the number of items in theList
if whichMonth is in item s of theList then exit repeat
end repeat
put proAm into last word of item s of theList
end if
repeat with y = 1 to 3
if bill is in field y of card whichMonth then
repeat with i = 1 to the number of lines in field y of card whichMonth
if bill = line i of field y of card whichMonth then
put proAm into line i of field (y + 1) of card whichMonth
exit repeat
end if
end repeat
exit repeat
end if
end repeat
repeat with i = 1 to the number of lines in allExpenses
if bill = item 1 of line i of allExpenses then
put theList into line i of card field "allExpenses" of card "whichMonths"
exit repeat
end if
end repeat
end if
end repeat
end repeat
end doEstimate
on doMath
set cursor to 4
set loc of msg to 19,106
put "Calculating, please wait."
set numberFormat to "0.00"
put "0" into temp4
repeat with x = 2 to 13
put "0" into temp2
repeat with i = 1 to the number of lines in field 2 of card x
put line i of field 2 of card x into temp1
delete char 1 of temp1
add temp1 to temp2
end repeat
repeat with i = 1 to the number of lines in field 4 of card x
put line i of field 4 of card x into temp1
delete char 1 of temp1
add temp1 to temp2
end repeat
put "$" & temp2 into field "subTotal" of card x
put "$" & temp2 & return after temp3
put temp2 & return after tempAm
add temp2 to temp4
end repeat
put temp3 into card field "amounts" of card "Year Totals"
put "$" & temp4 into card field "Total" of card "Year Totals"
put temp4 into deposit
divide deposit by 12
put "$" & deposit into card field "deposit/month" of card "Year Totals"
get word 1 of card field "pays" of card "Year Totals"
put temp4 into eachPay
divide eachPay by it
put "$" & eachPay into card field "perPay" of card "Year Totals"
put "0" into tempDep
get line 1 of card field "startMonth" of card "Year Totals"
if it = empty then
put "January" into line 1 of card field "startMonth" of card "Year Totals"
put "template" into line 3 of card field "startMonth" of card "Year Totals"
put card field "months" of card "Year Totals" into field "months" of card "template"
put "January" && "1," & last item of the long date into startDate
convert startDate to dateItems
get the date
convert it to dateItems
set numberFormat to "0"
if item 2 of it >= item 2 of startDate then add 1 to item 1 of startDate
convert startDate to date
convert startDate to seconds
put startDate into line 2 of card field "startMonth" of card "Year Totals"
put "January" into it
end if
repeat with i = 1 to 12
if it = line i of card field "months" of card "Year Totals" then exit repeat
end repeat
set numberFormat to "0.00"
repeat 12
add deposit to tempDep
put tempDep - line i of tempAm into line i of tempBal
put line i of tempBal into tempDep
if i = 12 then put 1 into i
else add 1 to i
end repeat
repeat with i = 1 to 12
put "$" before char 1 of line i of tempBal
end repeat
put tempBal into card field "balance" of card "Year Totals"
hide msg
end doMath
on closeStack
global saveMsg
if the diskSpace >= size of this stack then
get the freeSize of stack
if it > 1024 * 10 then
put trunc(it/1024) + 1 into extra
answer extra & "K of free space...compact stack?" with "Cancel" or "Compact"
if it = "Compact" then
if the userLevel < 4 then
put the userLevel into saveLevel
set the userLevel to 5
doMenu "Compact Stack"
set the userLevel to saveLevel
else
doMenu "Compact Stack"
end if
end if
end if
end if
set loc of msg to saveMsg
show menuBar
end closeStack